import { NativeModules } from 'react-native';

const create = (): void => {
  if (NativeModules.HttpServer.create) {
    NativeModules.HttpServer.create();
  }
};

const stop = (): void => {
  if (NativeModules.HttpServer.stop) {
    NativeModules.HttpServer.stop();
  }
};

const startWithPort = (port = 21994): void => {
  if (NativeModules.HttpServer.startWithPort) {
    NativeModules.HttpServer.startWithPort(port);
  }
};

const start = (): void => {
  startWithPort();
};

export default {
  create,
  start,
  stop,
  startWithPort
};
